package org.flashIso.engine.core {
	import flash.events.Event;
	
	import org.flashIso.engine.events.IsoEvent;

	/**
	 * @author Marius Dorin Moraru
	 */
	public class FillList extends ValidateableObject {
		private var _fills : Vector.<FillDescriptor>;

		public function FillList() {
			_fills = new Vector.<FillDescriptor>();
		}

		public function get length() : uint {
			return _fills.length;
		}

		public function add(fill : FillDescriptor) : void {
			_fills.push(fill);
			fill.addEventListener(Event.CHANGE, triggerValidation, false, 0, true);
			triggerValidation();
		}

		public function getItemAt(index : uint) : FillDescriptor {
			return _fills[index];
		}

		public function removeAll() : void {
			var i : uint;
			for (i = 0; i < _fills.length; i++ ) {
				FillDescriptor(_fills[i]).removeEventListener(Event.CHANGE, triggerValidation);
			}
			_fills = new Vector.<FillDescriptor>();
			triggerValidation();
		}
	}
}
